//
//  WPMoneyViewController.m
//  ZhongChouPingTai
//
//  Created by WeiPan on 16/4/1.
//  Copyright © 2016年 HuaYiSoftware. All rights reserved.
//

#import "WPMoneyViewController.h"
#import "WPDrawCashViewController.h"


@interface WPMoneyViewController ()
@property (nonatomic, strong) UIView * accountView;
@property (nonatomic, strong) UIImageView * logoImageView;
@property (nonatomic, strong) UITextField * leftTextField;
@property (nonatomic, strong) UITextField * usableTextField;
@property (nonatomic, strong) UITextField * freezeTextField;
@property (nonatomic, strong) UIImageView * directImageView;
@property (nonatomic, strong) UIView * topupView;
@property (nonatomic, strong) UIView * drawCashView;
@property (nonatomic, strong) UIView * payPwdManagerView;
- (void)initializeDataSource; /**< 初始化数据源 */
- (void)initializeUserInterface; /**< 初始化用户界面 */
- (void)refreshData;/**< 刷新数据 */


@end

@implementation WPMoneyViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self initializeDataSource];
    [self initializeUserInterface];
}
#pragma mark - init
- (void)initializeDataSource {
    
}
- (void)initializeUserInterface {
    [self.view addSubview:self.accountView];
    [self.view addSubview:self.topupView];
    [self.view addSubview:self.drawCashView];
    [self.view addSubview:self.payPwdManagerView];
}
#pragma mark - responds events
- (void)respondsToAccountViewTap {
    [self pushToNextController:[[NSClassFromString(@"WPDetailWalletViewController") alloc]init] withVCTitle:@"账户明细"];

}
- (void)respondsToTopup {
    [self pushToNextController:[[NSClassFromString(@"WPTopupViewController") alloc]init] withVCTitle:@"充值"];
}
- (void)respondsToDrawCash {
    WPDrawCashViewController * vc = [WPDrawCashViewController new];
    [self pushToNextController:vc withVCTitle:@"提现"];
}
- (void)respondsToPayPwdManagerViewTap {
    [self pushToNextController:[[NSClassFromString(@"WPSetPayPwdViewController") alloc]init] withVCTitle:@"支付密码"];
}
#pragma mark - 刷新数据
- (void)refreshData {
    
}
#pragma mark - getter
- (UIView *)accountView {
    if (!_accountView) {
        _accountView = ({
            UIView * view = [[UIView alloc]initWithFrame:CGRectMake(0, navBar_Fheight, SCREEN_SIZE.width, 103*DHFlexibleHorizontalMutiplier())];
            UITapGestureRecognizer * ges = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(respondsToAccountViewTap)];
            [view addGestureRecognizer:ges];
            [view addSubview:self.logoImageView];
            [view addSubview:self.leftTextField];
            [view addSubview:self.usableTextField];
            [view addSubview:self.freezeTextField];
            UIView * line = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(view.bounds)-1, SCREEN_SIZE.width, 1)];
            line.backgroundColor = COLOR_RGB(220, 220, 220, 1);
            [view addSubview:line];
            [view addSubview:self.directImageView];
            view.backgroundColor = [UIColor whiteColor];
            view;
        });
    }
    return _accountView;
}
- (UIImageView *)logoImageView {
    if (!_logoImageView) {
        _logoImageView = ({
            UIImageView * view = [[UIImageView alloc]initWithFrame:CGRectMake(25*DHFlexibleHorizontalMutiplier(), 35*DHFlexibleHorizontalMutiplier(), 35*DHFlexibleHorizontalMutiplier(), 35*DHFlexibleHorizontalMutiplier())];
            view.image = IMAGE_NAME(@"账户余额.png");
            view;
        });
    }
    return _logoImageView;
}
- (UITextField *)leftTextField {
    if (!_leftTextField) {
        _leftTextField = ({
            UITextField * text = [[UITextField alloc]initWithFrame:CGRectMake(70*DHFlexibleHorizontalMutiplier(), 30*DHFlexibleHorizontalMutiplier(), 200, 20*DHFlexibleHorizontalMutiplier())];
            text.leftViewMode = UITextFieldViewModeAlways;
            UILabel * label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 80*DHFlexibleHorizontalMutiplier(), 20*DHFlexibleHorizontalMutiplier())];
            label.font = [UIFont boldSystemFontOfSize:16*DHFlexibleHorizontalMutiplier()];
            label.text = @"账户余额";
            text.leftView = label;
            text.textColor = COLOR_RGB(244, 144, 7, 1);
            text.userInteractionEnabled = NO;
            text.text = @"¥0";
            text;
        });
    }
    return _leftTextField;
}
- (UITextField *)usableTextField {
    if (!_usableTextField) {
        _usableTextField = ({
            UITextField * text = [[UITextField alloc]initWithFrame:CGRectMake(CGRectGetMinX(self.leftTextField.frame), CGRectGetMaxY(self.leftTextField.frame), 120*DHFlexibleHorizontalMutiplier(), 30*DHFlexibleHorizontalMutiplier())];
            text.leftViewMode = UITextFieldViewModeAlways;
            UILabel * label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 60*DHFlexibleHorizontalMutiplier(), 20*DHFlexibleHorizontalMutiplier())];
            label.font = [UIFont boldSystemFontOfSize:11*DHFlexibleHorizontalMutiplier()];
            label.textColor = COLOR_RGB(144, 144, 144, 1);
            label.text = @"可用余额：";
            text.leftView = label;
            text.textColor = COLOR_RGB(144, 144, 144, 1);
            text.font = [UIFont boldSystemFontOfSize:11*DHFlexibleHorizontalMutiplier()];
            text.userInteractionEnabled = NO;
            text.text = @"¥0.0";
            text;
        });
    }
    return _usableTextField;
}
- (UITextField *)freezeTextField {
    if (!_freezeTextField) {
        _freezeTextField = ({
            UITextField * text = [[UITextField alloc]initWithFrame:CGRectMake(200*DHFlexibleHorizontalMutiplier(), CGRectGetMaxY(self.leftTextField.frame), 120*DHFlexibleHorizontalMutiplier(), 30*DHFlexibleHorizontalMutiplier())];
            text.leftViewMode = UITextFieldViewModeAlways;
            UILabel * label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 60*DHFlexibleHorizontalMutiplier(), 20*DHFlexibleHorizontalMutiplier())];
            label.font = [UIFont boldSystemFontOfSize:12*DHFlexibleHorizontalMutiplier()];
            label.textColor = COLOR_RGB(144, 144, 144, 1);
            label.text = @"冻结余额：";
            text.leftView = label;
            text.textColor = COLOR_RGB(144, 144, 144, 1);
            text.userInteractionEnabled = NO;
            text.font = [UIFont boldSystemFontOfSize:11*DHFlexibleHorizontalMutiplier()];
            text.text = @"¥0.0";
            text;
        });
    }
    return _freezeTextField;
}
- (UIImageView *)directImageView {
    if (!_directImageView) {
        _directImageView = ({
            UIImageView * view = [[UIImageView alloc]initWithFrame:CGRectMake(295*DHFlexibleHorizontalMutiplier(), 47*DHFlexibleHorizontalMutiplier(), 5*DHFlexibleHorizontalMutiplier(), 9*DHFlexibleHorizontalMutiplier())];
            view.image = IMAGE_NAME(@"iconfont-xialaanniu.png");
            view;
        });
    }
    return _directImageView;
}

- (UIView *)topupView {
    if (!_topupView) {
        _topupView = ({
            UIView * view = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(self.accountView.frame), CGRectGetMidX(self.view.bounds), 48*DHFlexibleHorizontalMutiplier())];
            view.backgroundColor = [UIColor whiteColor];
            UIImageView * image = [[UIImageView alloc]initWithFrame:CGRectMake(45*DHFlexibleHorizontalMutiplier(), 12*DHFlexibleHorizontalMutiplier(), 23*DHFlexibleHorizontalMutiplier(), 24*DHFlexibleHorizontalMutiplier())];
            image.image = IMAGE_NAME(@"iconfont_cancel.png");
            UILabel * lab = [[UILabel alloc]initWithFrame:CGRectMake(80*DHFlexibleHorizontalMutiplier(), 12*DHFlexibleHorizontalMutiplier(), 79*DHFlexibleHorizontalMutiplier(), 24*DHFlexibleHorizontalMutiplier())];
            lab.text = @"充值";
            UIView * line = [[UIView alloc]initWithFrame:CGRectMake(CGRectGetMaxX(view.frame)-1, 13*DHFlexibleHorizontalMutiplier(), 1, 24*DHFlexibleHorizontalMutiplier())];
            line.backgroundColor = COLOR_RGB(144, 144, 144, 1);
            [view addSubview:line];
            [view addSubview:image];
            [view addSubview:lab];
            UITapGestureRecognizer * ges = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(respondsToTopup)];
            [view addGestureRecognizer:ges];
            view;
        });
    }
    return _topupView;
}
- (UIView *)drawCashView {
    if (!_drawCashView) {
        _drawCashView = ({
            UIView * view = [[UIView alloc]initWithFrame:CGRectMake(CGRectGetMaxX(self.topupView.frame), CGRectGetMaxY(self.accountView.frame), CGRectGetMidX(self.view.bounds), 48*DHFlexibleHorizontalMutiplier())];
            view.backgroundColor = [UIColor whiteColor];
            UIImageView * image = [[UIImageView alloc]initWithFrame:CGRectMake(45*DHFlexibleHorizontalMutiplier(), 12*DHFlexibleHorizontalMutiplier(), 23*DHFlexibleHorizontalMutiplier(), 24*DHFlexibleHorizontalMutiplier())];
            image.image = IMAGE_NAME(@"iconfont_chongzhiguanli");
            UILabel * lab = [[UILabel alloc]initWithFrame:CGRectMake(80*DHFlexibleHorizontalMutiplier(), 12*DHFlexibleHorizontalMutiplier(), 79*DHFlexibleHorizontalMutiplier(), 24*DHFlexibleHorizontalMutiplier())];
            lab.text = @"提现";
            [view addSubview:image];
            [view addSubview:lab];
            UITapGestureRecognizer * ges = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(respondsToDrawCash)];
            [view addGestureRecognizer:ges];
            view;
        });
    }
    return _drawCashView;
}
- (UIView *)payPwdManagerView {
    if (!_payPwdManagerView) {
        _payPwdManagerView = ({
            UIView * view = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(self.topupView.frame)+15*DHFlexibleHorizontalMutiplier(), SCREEN_SIZE.width, 45*DHFlexibleHorizontalMutiplier())];
            UIImageView * image = [[UIImageView alloc]initWithFrame:CGRectMake(12*DHFlexibleHorizontalMutiplier(), 15*DHFlexibleHorizontalMutiplier(), 15*DHFlexibleHorizontalMutiplier(), 15*DHFlexibleHorizontalMutiplier())];
            image.image = IMAGE_NAME(@"iconfont_zhifuchenggong.png");
            UILabel * lab = [[UILabel alloc]initWithFrame:CGRectMake(40*DHFlexibleHorizontalMutiplier(), 10*DHFlexibleHorizontalMutiplier(), 100*DHFlexibleHorizontalMutiplier(), 25
                                                                     *DHFlexibleHorizontalMutiplier())];
            lab.font = [UIFont systemFontOfSize:14*DHFlexibleHorizontalMutiplier()];
            lab.text = @"支付管理";
            [view addSubview:image];
            [view addSubview:lab];
            UILabel * label = [[UILabel alloc]initWithFrame:CGRectMake(200*DHFlexibleHorizontalMutiplier(), 10*DHFlexibleHorizontalMutiplier(), 70*DHFlexibleHorizontalMutiplier(), 25*DHFlexibleHorizontalMutiplier())];
            label.font = [UIFont systemFontOfSize:11*DHFlexibleHorizontalMutiplier()];
            label.textColor = COLOR_RGB(121, 121, 121, 1);
            label.text = @"设置支付密码";
            UIImageView * directImage = [[UIImageView alloc]initWithFrame:CGRectMake(295*DHFlexibleHorizontalMutiplier(), 18*DHFlexibleHorizontalMutiplier(), 5*DHFlexibleHorizontalMutiplier(), 9*DHFlexibleHorizontalMutiplier())];
            directImage.image = IMAGE_NAME(@"iconfont-xialaanniu.png");
            [view addSubview:label];
            [view addSubview:directImage];
            UIView * point = [[UIView alloc]initWithFrame:CGRectMake(CGRectGetMaxX(label.frame), 20*DHFlexibleHorizontalMutiplier(), 5*DHFlexibleHorizontalMutiplier(), 5*DHFlexibleHorizontalMutiplier())];
            point.backgroundColor = COLOR_RGB(252, 0, 6, 1);
            point.layer.cornerRadius = 2.5*DHFlexibleHorizontalMutiplier();
            [view addSubview:point];
            point.layer.masksToBounds = YES;
            UITapGestureRecognizer * ges = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(respondsToPayPwdManagerViewTap)];
            [view addGestureRecognizer:ges];
            view.backgroundColor = [UIColor whiteColor];
            view;
        });
    }
    return _payPwdManagerView;
}
@end
